package com.jeecms.wicool.manager.orders.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.jeecms.common.hibernate3.Updater;
import com.jeecms.common.page.Pagination;
import com.jeecms.wicool.dao.orders.OrderLogDao;
import com.jeecms.wicool.entity.orders.OrderLog;
import com.jeecms.wicool.entity.orders.Orders;
import com.jeecms.wicool.manager.orders.OrderLogMng;
import com.jeecms.wicool.manager.orders.OrdersMng;

@Service
@Transactional
public class OrderLogMngImpl implements OrderLogMng {
	
	private OrderLogDao dao;
	@Autowired
	public void setDao(OrderLogDao dao) {
		this.dao = dao;
	}
	
	@Transactional(readOnly = true)
	public Pagination getPage(Integer orderId,Short orderStatus,
			int pageNo, int pageSize) {
		Pagination page = dao.getPage(orderId, orderStatus, pageNo, pageSize);
		return page;
	}
	@Override
	public OrderLog findById(Integer id) {
		OrderLog entity = dao.findById(id);
		return entity;
	}

	
	@Override
	public List<OrderLog> getAll() {
		return dao.getAll();
	}
	@Override
	public List<OrderLog> getByOrderId(Integer OrderId) {
		return dao.getByOrderId(OrderId);
	}

	@Override
	public OrderLog udate(OrderLog bean, Integer orderId) {
		Orders order = orderMng.findById(orderId);
		bean.setDingdan(order);
		Updater<OrderLog> updater = new Updater<OrderLog>(bean);
		bean = dao.updateByUpdater(updater);
		return bean;
	}
	@Autowired
	private OrdersMng orderMng;
	@Override
	public OrderLog save(OrderLog bean) {
		
		return dao.save(bean);
	}

}